// Mouse and key properties
var mouse = { isDown: false, x: 0, y: 0 };
var keys = new Array(256);

function event_keyDown(event){
    keys[event.keyCode] = true
}

function event_keyUp(event){
    keys[event.keyCode] = false
}

// Set the key event handlders
document.onkeydown = event_keyDown
document.onkeyup = event_keyUp

function event_mouseDown(event) {
    mouse.isDown = true;
}

function event_mouseUp(event) {
    mouse.isDown = false;
}

function event_mouseMove(event) {
    mouse.x = event.clientX
    mouse.y = event.clientY
}

// A function for detecting is the mouse is down
function mouseIsDown() {
    return mouse.isDown == true;
}

function releaseMouse() {
    mouse.isDown = false;
}


// A function for detecting if a key is down
function keyIsDown(code) {
    return keys[code] == true
}

// A function for manually releasing a key
// To be used with certain actions were it shouldnt detect a key thats held down
function releaseKey(code) {
    keys[code] = false;
}